<template>
  <div>
    <user-form title="注册" @submit="onSubmit">
      <template #btn>
        <van-button block type="warning" native-type="submit">注册</van-button>
      </template>
      <router-link class="register-page" to="/login"
        >已有账号,去登录</router-link
      >
    </user-form>
  </div>
</template>

<script>
//导入请求模块
import requset from "@/utils/requset";
//导入API函数
import { requsetAPI } from "@/api/user";
//导入组件
import UserForm from "@/components/UserForm.vue";
export default {
  components: { UserForm },
  //请求注册接口
  methods: {
    async onSubmit(values) {
      //调用函数
      await requsetAPI(values);
      //注册成功  跳转到登陆页面
      this.$router.push("/login");
      //提示弹窗
      // alert("注册成功");
      this.$toast.success("注册成功");
    },
  },
};
</script>

<style>
.register-page {
  float: right;
  margin-right: 9px;
  font-size: 12px;
}
</style>